package main

import (
	"fmt"
	"reflect"
)

type X struct {

}

func (X) Format(s string,a ...interface{}) string  {
	return fmt.Sprintf(s,a...)
}

func main() {
	var a X
	v := reflect.ValueOf(&a)
	m := v.MethodByName("Format")

	out := m.Call([]reflect.Value{
		reflect.ValueOf("%s = %d"),
		reflect.ValueOf("x"),
		reflect.ValueOf(100),
	})
	fmt.Println(out)
	//对于变参，用CallSlice方便一些
	out = m.CallSlice([]reflect.Value{
		reflect.ValueOf("%s = %d"),
		reflect.ValueOf([]interface{}{"x",100}),
	})
	fmt.Println(out)
	//无法调用非导出方法，升值无法获取有效地址
}
